<template>
	<view id="app">
		<view>
			<view class="u-demo-area" style="width: 94%;margin-left:3%; text-align: center;margin-top: 10px;">
				<u-subsection @change="click" v-if="change" :bold="bold" :active-color="activeColor" :current="current" :mode="mode" 
				:list="listTabs" ></u-subsection>
			</view>
			<view style="padding-top: 18rpx;">
				<WaterRecord @myClick="myClick" :newlist="newlist"></WaterRecord>
			</view>
		</view>
	</view>
</template>
<script>
	import WaterRecord from '@/components/water/WaterInfo/index.vue';
	import { getRealType , getWaterInfo } from '../api/api.js'
	export default {
		data() {
			return {
				listTabs:["嘉兴","湖州","杭州","省外"],
				result:[],
				mode: 'subsection',
				current: 0,
				bold: false,
				change: true,
				activeColor: this.$u.color['primary'],
				treeId:"2020091714460798413",
				newlist:[]
			}
		},
		onLoad(options) {
			// uni.setNavigationBarTitle({
			// 	title: "水情报表"
			// });
			// uni.setNavigationBarColor({
			// 	frontColor: "#ffffff", //文字颜色
			// 	backgroundColor: "#1296db" //底部背景色
			// })
			this.search()
		},
		onReady(){
		},
		components: {
			WaterRecord
		},
		mounted() {
		},
		methods: {
			myClick(stcd,stnm) {
				//跳转到页面
				uni.navigateTo({
					url: '../waterDZ?stcd=' + stcd+'&stnm='+stnm
				})
			},
			click(e){
				this.current = e;
				this.search();
			},
			search() {
				// var data = {
				// 	ID: this.treeId 
				// }
				// var _param = {}
				// _param.data = data;
				// getRealType(_param).then(res =>{
				// 	var listData = res.data;
				// 	for(var i= 0 ;i< listData.length; i++) {
				// 		//this.result.push(listData[i].TITLE);
				// 		this.result.push({"id":listData[i].ID,"name": listData[i].TITLE});
				// 	}
				// 	console.log(JSON.stringify(this.listTabs))
				// 	if(this.listTabs.length > 0){
				// 		this.change = true;
				// 	}
				// 	this.listTabs = this.result;
				// 	console.log(JSON.stringify(this.listTabs))
				// })
				this.listTabs = [{"id":"2021032401213699261","name":"嘉兴"},{"id":"2021032401250723802","name":"湖州"},{"id":"2021032401265434589","name":"杭州"},{"id":"2021070711285412413","name":"省外"}];
				var _data = {
					STIME: new Date(new Date().addDate("d",-1)).Format("YYYY-MM-DD hh:mm:ss"),
					ETIME: new Date(new Date().addDate("d",1)).Format("YYYY-MM-DD hh:mm:ss"),
					TREEID: this.listTabs[this.current].id//"2020111911490888935"
				};
				var _param = {}
				_param.data = _data;
				
				getWaterInfo(_param).then(res =>{
					this.newlist = res.data;
				})
			}
		}
	}
	
</script>

<style>
</style>
